<template>
    <div class="ele-body">
        <el-card shadow="never">
            <el-form
                :model="where"
                label-width="77px"
            >
                <el-form-item label="浮标icon:">
                    <uploadImageFin :limit="1" v-model="where.icon"></uploadImageFin>
                </el-form-item>
                <el-form-item label="logo:">
                    <uploadImageFin :limit="1" v-model="where.logo"></uploadImageFin>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="save" :loading="loading"
                        >保存
                    </el-button>
                </el-form-item>
            </el-form> 
        </el-card>
    </div>
</template>
<script>
import uploadImageFin from "@/components/uploadImageFin";
export default {
    components: { uploadImageFin },
    data(){
        return{
            where:{
                icon:'',
                logo:'',
            },
            loading:false,
            
        }
    },
    created(){
        this.queryWhere()
    },
    methods:{
        //獲取默認配置
        queryWhere(){
            this.$http.post('/Defaultconfig/getDefaultConfig',{name:'sdk_site'}).then(res=>{
                console.log(res)
                if(res.data.code === 0){
                    this.where.icon=res.data.data.icon;
                    this.where.logo=res.data.data.logo;
                }else{
                    this.$message.error(res.data.msg);
                }
            })
        },
        //保存默認配置
        save(){
            this.$http.post('/Defaultconfig/setDefaultConfig',{name:'sdk_site',icon:this.where.icon,logo:this.where.logo}).then(res=>{
                if(res.data.code === 0){
                    this.$message.success('保存成功!');
                    this.queryWhere()
                }else{
                    this.$message.error(res.data.msg);
                }
            })
        },
    }
}
</script>
<style scoped></style>